package com.example.demo;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@Slf4j
@SpringBootApplication
@EnableFeignClients
@EnableEurekaClient
public class ShopApp {

	public static void main(String[] args) throws UnknownHostException {
		SpringApplication springApplication = new SpringApplication(ShopApp.class);
		springApplication.setBannerMode(Banner.Mode.OFF);
		ConfigurableApplicationContext application = springApplication.run(args);
		Environment env = application.getEnvironment();
		String host = InetAddress.getLocalHost().getHostAddress();
		String port = env.getProperty("server.port");
		String appName = env.getProperty("spring.application.name");
		log.info("\n----------------------------------------------------------\n\t" +
						"Application '{}' is running! Access URLs:\n\t" +
						"Local: \t\thttp://localhost:{}\n\t" +
						"External: \thttp://{}:{}\n\t" +
						"Doc: \t\thttp://{}:{}/doc.html\n" +
						"----------------------------------------------------------",
				appName,
				port,
				host,
				port,
				host,
				port);
	}

}
